package umacis.core;

import java.util.Vector;

import com.sun.lwuit.util.Log;

import systemviews.OutlineView;
import umacis.data.description.ApplicationDescription;
import umacis.data.description.ApplicationViewDescription;
import umacis.data.view.ApplicationView;
import umacis.data.view.SystemView;
import umacis.data.view.View;
import umacis.lwuitcomponent.property.Properties;

public class Application {
	
	
	private Vector appViews = new Vector();
	
	private ApplicationDescription applicationDescription;

	private int currentViewShowing;
	
	
	public Application(ApplicationDescription applicationDescription) {
		this.applicationDescription = applicationDescription;
	}
	
	public void show() {
		if (applicationDescription.getNumberOfViewDescriptions() == 0) {//XXX maybe show system dialog iso making default view..
			ApplicationViewDescription emptyViewDescription = new ApplicationViewDescription("Empty screen");
			applicationDescription.addViewDescription(emptyViewDescription);
			appViews.addElement(new ApplicationView(emptyViewDescription));
			 
		}
		showApplicationView(applicationDescription.getStartupViewIndex());
	}
	
	
	private void showApplicationView(int viewIndex) {
		currentViewShowing = viewIndex;
		((ApplicationView)appViews.elementAt(viewIndex)).show(applicationDescription.getPropertiesToImpose());
		
	}
	
	public ApplicationView getCurrentApplicationView() {
		return ((ApplicationView)appViews.elementAt(currentViewShowing));
	}
	
	
}
